<template>
  <div>
    <!-- js -->
    <remote-js src="./assets/js/email-decode.min.js"></remote-js>
    <remote-js src="./assets/js/popper.min.js"></remote-js>
    <remote-js src="./assets/js/bootstrap.min.js"></remote-js>
    <remote-js src="./assets/js/color-switcher.js"></remote-js>
    <remote-js src="./assets/js/jquery.counterup.min.js"></remote-js>
    <remote-js src="./assets/js/waypoints.min.js"></remote-js>
    <remote-js src="./assets/js/wow.js"></remote-js>
    <remote-js src="./assets/js/owl.carousel.min.js"></remote-js>
    <remote-js src="./assets/js/nivo-lightbox.js"></remote-js>
    <remote-js src="./assets/js/jquery.slicknav.js"></remote-js>
    <remote-js src="./assets/js/main.js"></remote-js>
    <remote-js src="./assets/js/form-validator.min.js"></remote-js>
    <remote-js src="./assets/js/contact-form-script.min.js"></remote-js>
    <remote-js src="./assets/js/summernote.js"></remote-js>

    <header id="header-wrap">

      <nav class="navbar navbar-expand-lg fixed-top scrolling-navbar">
        <div class="container">

          <div class="navbar-header">
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#main-navbar"
              aria-controls="main-navbar" aria-expanded="false" aria-label="Toggle navigation">
              <span class="navbar-toggler-icon"></span>
              <span class="lni-menu"></span>
              <span class="lni-menu"></span>
              <span class="lni-menu"></span>
            </button>
            <a href="index.html" class="navbar-brand"><img src="./assets/img/logo.png" alt=""></a>
          </div>
          <div class="collapse navbar-collapse" id="main-navbar">
            <ul class="navbar-nav mr-auto">
              <li class="nav-item" :class="{ active: activeNav == 'soft' }" @click="activeNav = 'soft'">
                <a class="nav-link">
                  <RouterLink to="/index/soft" style="color: aquamarine;">
                    首页
                  </RouterLink>
                </a>
              </li>
              <li class="nav-item dropdown" :class="{ active: activeNav == 'study' }" @click="activeNav = 'study'">
                <a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-haspopup="true"
                  aria-expanded="false" style="color: aquamarine;">
                  资料
                </a>
                <div class="dropdown-menu" style="background-color: rgba(127, 255, 212, 0.247);">
                  <a class="dropdown-item" >
                    <RouterLink to="/videos" style="color: #ffffff;">  视频</RouterLink>
                  </a>
                  <a class="dropdown-item" >
                    <RouterLink to="/books" style="color: #ffffff;">  文章</RouterLink>
                  </a>
                  <a class="dropdown-item" >
                    <RouterLink to="/chm" style="color: #ffffff;">  文档</RouterLink>
                  </a>
                  <a class="dropdown-item" >
                    <RouterLink to="/source" style="color: #ffffff;">  资源</RouterLink>
                  </a>
                </div>
              </li>
              <!-- <li class="nav-item " :class="{ active: activeNav == 'PC' }" @click="activeNav = 'PC'">
                <a class="nav-link">
                  <RouterLink to="/index/soft" style="color: aquamarine;">
                    PC
                  </RouterLink>
                </a>
              </li>
              <li class="nav-item" :class="{ active: activeNav == 'PE' }" @click="activeNav = 'PE'">
                <a class="nav-link">
                  <RouterLink to="/index/soft" style="color: aquamarine;">
                    PE
                  </RouterLink>
                </a>
              </li>
              <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-haspopup="true"
                  aria-expanded="false">
                  Listings
                </a>
                <div class="dropdown-menu">
                  <a class="dropdown-item" href="adlistinggrid.html">Ad Grid</a>
                  <a class="dropdown-item" href="adlistinglist.html">Ad Listing</a>
                  <a class="dropdown-item" href="ads-details.html">Listing Detail</a>
                </div>
              </li> -->
            </ul>
            <!-- <ul class="sign-in">
              <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-haspopup="true"
                  aria-expanded="false"><i class="lni-user"></i> DUXIANG</a>
                <div class="dropdown-menu">
                  <a class="dropdown-item" href="account-profile-setting.html"><i class="lni-home"></i> Account Home</a>
                  <a class="dropdown-item" href="account-myads.html"><i class="lni-wallet"></i> My Ads</a>
                  <a class="dropdown-item" href="account-favourite-ads.html"><i class="lni-heart"></i> Favourite ads</a>
                  <a class="dropdown-item" href="account-archived-ads.html"><i class="lni-folder"></i> Archived</a>
                  <a class="dropdown-item" href="login.html"><i class="lni-lock"></i> Log In</a>
                  <a class="dropdown-item" href="signup.html"><i class="lni-user"></i> Signup</a>
                  <a class="dropdown-item" href="forgot-password.html"><i class="lni-reload"></i> Forgot Password</a>
                  <a class="dropdown-item" href="account-close.html"><i class="lni-close"></i>Account close</a>
                </div>
              </li>
            </ul> -->
          </div>
        </div>
      </nav>


      <div id="hero-area">
        <div class="overlay"></div>
        <div class="container" :class="{hiddenSearch:hiddenSearch}">
          <div class="row">
            <div class="col-md-24 col-lg-24 col-xs-24 text-center">
              <div class="contents">
                <!-- <h1 class="head-title">Welcome to <span class="year">ClassiAlly</span></h1> -->
                <p></p>
                <div class="search-bar">
                  <fieldset>
                    <form class="search-form">
                      <div class="form-group tg-inputwithicon">
                        <i class="lni-tag"></i>
                        <input v-model="searchKey" type="text" name="customword" class="form-control" placeholder="关键字搜索">
                      </div>
                      <button class="btn btn-common" type="button" @click="search"><i class="lni-search"></i></button>
                    </form>
                  </fieldset>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

    </header>

    <RouterView></RouterView>
  </div>
</template>

<script>
import { ref, h } from "vue"
import { RouterView, RouterLink } from "vue-router";
import commonjs from "@/api/common.js"
export default {
  data() {
    return {
      activeNav: "soft",
      searchKey: "",
      hiddenSearch:false
    }
  },
  components: {
    'remote-js': {
      render() {
        return h('script', { attrs: { type: 'text/javascript', src: this.src } });
      },
      props: {
        src: { type: String, required: true },
      },
    },
  },
  created() {
    let obj = commonjs.fun.getLocationSearch("searchKey")
    this.searchKey = obj.searchKey,
    this.flagSearchHidden()
  },
  methods: {
    search() {
      this.$router.push({ path: '/index/soft', query: { searchKey: this.searchKey } })
    },
    flagSearchHidden(){
      let route = this.$route
      if(route.path == '/index/detail'){
        this.hiddenSearch = true
      }else{
        this.hiddenSearch = false
      }
    }
  },
  watch:{
    '$route'(to,from){
      if(to.path == '/index/detail'){
        this.hiddenSearch = true
      }else{
        this.hiddenSearch = false
      }
    }
  }
}
</script>
<style scoped>
/* //引入css类 */
@import url(./assets/css/bootstrap.min.css);
@import url(./assets/fonts/line-icons.css);
@import url(./assets/css/main.css);

.search-bar .form-group {
  width: 100% !important;
  float: none !important;
}
.hiddenSearch{
  height: 100px;
  overflow-y: hidden;
}
</style>